<template>
  <div class="info-div">
    <div class="nav">
      <div class="myself">
        <el-avatar :size="50" :src="defaultSrc" style="margin-left: 40px;margin-right: 30px"></el-avatar>
        <span>{{ username }}</span>
      </div>
      <div class="nav2">
        <div class="conDay">
          <div>
            <div class="nav2_first">{{ conDay }}</div>
          </div>
          <div>
            <div class="nav2_second">已连续打卡</div>
          </div>
        </div>
        <div class="allDay">
          <div>
            <div class="nav2_first">{{ allDay }}</div>
          </div>
          <div>
            <div class="nav2_second">记账总天数</div>
          </div>
        </div>
        <div class="allNum">
          <div>
            <div class="nav2_first">{{ allNum }}</div>
          </div>
          <div>
            <div class="nav2_second">记账总笔数</div>
          </div>
        </div>
      </div>
      <div class="card1">
        <div class="function" @click="getMessage">
          <div>
            <img class="pic" src="@/assets/icons/png/xiaoxi.png"/>
          </div>
          <div>
            <div class="span1">消息</div>
          </div>
        </div>
        <div class="function" @click="getHuiZhang">
          <div>
            <img class="pic" src="@/assets/icons/png/huizhang.png"/>
          </div>
          <div>
            <div class="span1">徽章</div>
          </div>
        </div>
        <div class="function" @click="getSetting">
          <div>
            <img class="pic" src="@/assets/icons/png/shezhi.png"/>
          </div>
          <div>
            <div class="span1">设置</div>
          </div>
        </div>
      </div>
      <div class="card2">
        <div class="card2_fun">
          <img class="img1" src="@/assets/icons/png/wdzb.png"/>
          <span class="text"> 我的账本</span>
          <img class="enter" :src="enterSrc"/>
        </div>
        <div class="card2_fun">
          <img class="img1" src="@/assets/icons/png/jtzd.png"/>
          <span class="text"> 家庭账单</span>
          <img class="enter" :src="enterSrc"/>
        </div>

      </div>
      <div class="card2">
        <div class="card2_fun" @click="getSetting">
          <img class="img1" src="@/assets/icons/png/setting.png"/>
          <span class="text"> 设置</span>
          <img class="enter" :src="enterSrc"/>
        </div>
        <div class="card2_fun">
          <img class="img1" src="@/assets/icons/png/safe.png"/>
          <span class="text"> 账号安全中心</span>
          <img class="enter" :src="enterSrc"/>
        </div>
        <div class="card2_fun">
          <img class="img1" src="@/assets/icons/png/help.png"/>
          <span class="text"> 使用帮助</span>
          <img class="enter" :src="enterSrc"/>
        </div>
        <div class="card2_fun">
          <img class="img1" src="@/assets/icons/png/return.png"/>
          <span class="text"> 意见反馈</span>
          <img class="enter" :src="enterSrc"/>
        </div>
        <div class="card2_fun" @click="$router.push('/')">
          <img class="img1" src="@/assets/icons/png/return.png"/>
          <span class="text"> 退出</span>
          <img class="enter" :src="enterSrc"/>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
import router from "@/router";

export default {
  name: 'myInfoView',

  data() {
    return {
      defaultSrc: require("@/assets/icons/png/avatar.png"),
      enterSrc: require("@/assets/icons/png/enter.png"),
      username: "",
      conDay: 1,
      allDay: 200,
      allNum: 30,
    }
  },
  created() {
    var avatar = window.localStorage.getItem("avatar");
    if (avatar != "" && avatar != "null") {
      this.src = require(avatar)
    }
    this.username = window.localStorage.getItem("username");
  },
  methods: {
    // 跳转至徽章页面
    getHuiZhang() {
      router.push("/myHuiZhang");
    },
    // 跳转至信息页面
    getMessage() {
      router.push("/message");
    },
    // 跳转至设置页面
    getSetting() {
      router.push("/setting");
    }
  }
}
</script>
<style scoped>
.info-div {
  background-color: #fbfbfb;
  width: 100%;
  height: 100%;
  top: 0;
  position: fixed;
}

.nav {
  width: 100%;
  background-color: rgb(251, 219, 68);
  height: 180px;
  margin: 0;
  padding: 0;
  top: 0;
  left: 0;
  text-align: center;
  position: fixed;
}

.myself {
  display: flex;
  align-items: center; /* 垂直居中 */
  justify-content: flex-start; /* 水平居中距左 */
  margin-top: 20px;
}

.nav2 {
  display: flex;
  flex-wrap: wrap; /* 允许项目在容器中换行 */
  justify-content: space-around; /* 均匀分布项目 */
  align-items: center; /* 垂直居中对齐项目 */
  margin-top: 20px;
}

.nav2_second {
  width: 120px;
}

.card1 {
  z-index: 999;
  width: 90%;
  height: 70px;
  background-color: white;
  margin: 20px auto;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap; /* 允许项目在容器中换行 */
  justify-content: space-around; /* 均匀分布项目 */
  align-items: center; /* 垂直居中对齐项目 */
}

.card1 .function {
  height: 80px;
}

.card1 .function .pic {
  height: 30px;
  width: 30px;
  margin-top: 10px;
}

.card2 {
  z-index: 999;
  width: 90%;
  background-color: white;
  margin: 20px auto;
  border-radius: 6px;
}


.card2_fun {
  height: 45px;
  position: relative; /* 添加相对定位 */
}

.card2_fun:after {
  content: "";
  display: block;
  width: 70%;
  height: 1px; /* 横线的厚度 */
  background-color: #c7c4c4; /* 横线的颜色 */
  position: absolute; /* 绝对定位 */
  bottom: 0; /* 定位在底部 */
  margin-left: 50px;
}

.card2_fun:last-child:after {
  /* 最后一个div不需要横线 */
  content: none;
}

.img1 {
  width: 30px;
  height: 30px;
  float: left;
  margin-left: 15px;
  line-height: 45px;
  margin-top: 6px;
}

.text {
  margin-left: 15px;
  float: left;
  line-height: 45px;
}

.enter {
  height: 30px;
  float: right;
  width: 30px;
  margin-right: 15px;
  color: #999999;
  line-height: 30px;
  margin-top: 6px;
}

</style>